import { onMounted } from 'vue';
import { invokeAsyncAPi } from '@/utils/xz-fn'

const useSetWindowDragSize = () => {
  onMounted(() => {
    const { left, right } = document.body.getBoundingClientRect();
    const allWidth = left + right;
    const noDragList = [];//不能拖拽的区域


    //获取哪些是不能拖拽的
    for (const item of document.querySelectorAll('._no_drag_area')) {
      const { left, right } = item.getBoundingClientRect()
      noDragList.push([left>>0, right>>0])
    }
    const canDragList = [];//可以拖拽的区域
    let start = 0;//开始的位置
    for (const [left, right] of noDragList) {
      canDragList.push({
        top: 0,
        bottom: 50,
        left: start,
        right: left
      });
      start = right;
    }
    canDragList.push({
      top: 0,
      bottom: 50,
      left: start,
      right: allWidth
    })

    invokeAsyncAPi('jsMsg_SetWndDragPos', canDragList)

  })
}

export default useSetWindowDragSize